import request from '@/utils/request'

/**
 * 添加服务的数据服务配置
 */
export function addDataService(data) {
  return request({
    method: 'post',
    url: '/resource/data/service/add',
    data: data
  })
}

/**
 * 添加服务的数据新版服务配置
 */
export function mountDataService(data) {
  return request({
    method: 'post',
    url: '/resource/map/service/add',
    data: data
  })
}

/**
 * 查询数据服务配置列表
 */
export function retrieveDataServiceList(data) {
  return request({
    method: 'get',
    url: '/resource/data/service/queryList',
    params: data
  })
}

/**
 * 查询新版数据服务配置列表
 */
export function retrieveDataServiceById(data) {
  return request({
    method: 'get',
    url: '/resource/map/service/queryById',
    params: data
  })
}

/**
 * 删除数据服务配置
 */
export function deleteDataService(data) {
  return request({
    method: 'delete',
    url: `/resource/data/service/delete?pkids=${data}`
  })
}

/**
 * 删除新版数据服务配置
 */
export function deleteNewDataService(data) {
  return request({
    method: 'delete',
    url: `/resource/map/service/delete?idList=${data}`
  })
}

/**
 * 修改数据服务配置
 */
export function updateDataService(data) {
  return request({
    method: 'post',
    url: '/resource/data/service/update',
    data: data
  })
}

/**
 * 指定目录节点挂载附件
 *
 * fileId, fileName, catalogId, releaseTime
 */
export function addAttachmentToCatalog(data) {
  return request({
    method: 'post',
    url: '/resource/datacatalog/file/add',
    data: data
  })
}

/**
 * 查询指定目录节点的附件
 *
 * fileName, realName, catalogId, pageIndex, pageSize
 */
export function retrieveAttachmentInCatalog(data) {
  return request({
    method: 'get',
    url: '/resource/datacatalog/file/query',
    params: data
  })
}

/**
 * 编辑指定目录节点的附件(只能更新文件名和发布时间)
 *
 * pkid, fileName, releaseTime
 */
export function updateAttachmentInCatalog(data) {
  return request({
    method: 'put',
    url: '/resource/datacatalog/file/update',
    data: data
  })
}

/**
 * 编辑指定目录节点附件的顺序
 *
 * catalogId, resourceId(资源id), resourceType(资源类型，文件为8), frontResourceId(前一个id，如果拖到第一个则为-1)
 */
export function updateAttachmentOrderInCatalog(data) {
  return request({
    method: 'put',
    url: '/resource/datacatalog/update/resource/orderIndex',
    data: data
  })
}

/**
 * 删除指定目录节点下的附件
 *
 * fileId, catalogId
 */
export function deleteAttachmentInCatalog(data) {
  return request({
    method: 'delete',
    url: '/resource/datacatalog/file/delete',
    params: data
  })
}

/**
 * 关联关系图片查询
 *
 * mainPictureId, childPictureId
 */
export function retrievePictureInRelation(data) {
  return request({
    method: 'get',
    url: '/resource/data/picture/rel/queryList',
    params: data
  })
}

/**
 * 关联关系图片新增
 *
 * [mainPictureId, childPictureId]
 */
export function addPictureInRelation(data) {
  return request({
    method: 'post',
    url: '/resource/data/picture/rel/add',
    data: data
  })
}

/**
 * 关联关系图片删除
 */
export function deletePictureInRelation(
  childIds,
  mainPictureId
) {
  return request({
    method: 'delete',
    url: `/resource/data/picture/rel/delete?childIds=${childIds}&mainPictureId=${mainPictureId}`
  })
}

/**
 * 关联关系图片顺序
 *
 * childPictureId, mainPictureId, frontId
 */
export function updateRelationPicturesOrder(data) {
  return request({
    method: 'put',
    url: '/resource/data/picture/rel/update',
    data: data
  })
}

/*
 * 修改新版数据服务配置
 */
export function modifyDataService(data) {
  return request({
    method: 'post',
    url: '/resource/map/service/saveOrUpdate',
    data: data
  })
}

/**
 * 查询数据服务配置附件列表
 */
export function queryAttachmentList(data) {
  return request({
    method: 'get',
    url: '/resource/data/attachment/queryAttachmentList',
    params: data
  })
}
/**
 * 查询数据服务配置列表
 */
export function queryConfigList(params) {
  return request({
    method: 'get',
    url:
      '/resource/data/service/queryConfig?serviceDataId=' +
      params
  })
}
/**
 * 添加服务的数据服务配置附件
 */
export function addAttachment(data) {
  return request({
    method: 'post',
    url: '/resource/data/attachment/addAttachment',
    data: data
  })
}

/**
 * 更新数据服务配置附件
 */
export function updateAttachment(data) {
  return request({
    method: 'post',
    url: '/resource/data/attachment/updateAttachment',
    data: data
  })
}

/**
 * 删除数据服务配置附件
 */
export function deleteAttachment(data) {
  return request({
    method: 'delete',
    url: `/resource/data/attachment/deleteAttachment?pkids=${data}`
  })
}

/**
 * 数据服务配置附件汇总
 */
export function queryAllAttachment(data) {
  return request({
    method: 'get',
    url: '/resource/data/service/queryAttachmentTotal',
    params: data
  })
}

/**
 * 查询数据服务配置图片
 */
export function queryAllPicture(data) {
  return request({
    method: 'get',
    url: '/resource/data/service/queryAllPicture',
    params: data
  })
}

/**
 * 添加服务的数据服务配置图片
 */
export function addPicture(data) {
  return request({
    method: 'post',
    url: '/resource/data/picture/addPicture',
    data: data
  })
}

/**
 * 更新数据服务配置图片
 */
export function updatePicture(data) {
  return request({
    method: 'post',
    url: '/resource/data/picture/updatePicture',
    data: data
  })
}

/**
 * 删除数据服务配置图片
 */
export function deletePicture(data) {
  return request({
    method: 'delete',
    url: `/resource/data/picture/deletePicture?pkids=${data}`
  })
}

/**
 * 查询数据服务配置附件阶段去重列表
 */
export function queryDistinctStage(data) {
  return request({
    method: 'get',
    url: '/resource/data/attachment/queryDistinctStage',
    params: data
  })
}

/**
 * 查询数据服务配置附件阶段节点去重列表
 */
export function queryDistinctNode(data) {
  return request({
    method: 'get',
    url: '/resource/data/attachment/queryDistinctNode',
    params: data
  })
}

/**
 * 查询数据服务配置图片类型去重列表
 */
export function queryDistinctPictureType(data) {
  return request({
    method: 'get',
    url: '/resource/data/picture/queryDistinctPictureType',
    params: data
  })
}

/**
 * 数据服务配置附件汇总
 */
export function queryAttachmentTotal(data) {
  return request({
    method: 'get',
    url: '/resource/data/attachment/queryAttachmentTotal',
    params: data
  })
}

/**
 * 获取关联附件数据
 */
export function queryAttachmentById(data) {
  return request({
    method: 'get',
    url: `/resource/attachment/fileRel/queryList?attachmentId=${data}`
  })
}

/**
 * 数据配置关联附件新增
 */
export function addAttachmentFileRel(data) {
  return request({
    method: 'post',
    url: '/resource/attachment/fileRel/add',
    data: data
  })
}
/**
 * 数据配置关联附件更新
 */
export function updateAttachmentFileRel(data) {
  return request({
    method: 'post',
    url: '/resource/attachment/fileRel/update',
    data: data
  })
}

/**
 * 删除数据服务配置关联附件
 */
export function deleteAttachmentFileRel(data) {
  return request({
    method: 'delete',
    url: `/resource/attachment/fileRel/delete?pkid=${data}`
  })
}

/**
 * 查询新版数据服务配置列表
 */
export function getResourceConfig(data) {
  return request({
    method: 'get',
    url: '/resource/config/query',
    params: data
  })
}
